package com.example.icedcap.topeka_fake.widget.fab;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;

import com.example.icedcap.topeka_fake.R;

/**
 * Author: doushuqi
 * Date: 15/7/17
 * Time: 下午2:58
 * Email: shuqi.dou@singuloid.com
 */
public class CheckableFab extends FloatingActionButton implements Checkable {
    private static final int[] CHECKED = {android.R.attr.state_checkable};
    private boolean mIsChecked = true;
    public CheckableFab(Context context) {
        this(context, null);
    }

    public CheckableFab(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CheckableFab(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setImageResource(R.drawable.answer_quiz_fab);
    }

    @Override
    public void setChecked(boolean checked) {
        if (mIsChecked == checked) {
            return;
        }
        mIsChecked = checked;
        refreshDrawableState();
    }

    @Override
    public boolean isChecked() {
        return mIsChecked;
    }

    @Override
    public void toggle() {
        setChecked(!mIsChecked);
    }
}
